package drawer1;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CanavasEditor implements ActionListener,MouseListener{
	private JButton cbutton;
	public CanavasEditor(JButton b){
		cbutton = b;
	}
	public void actionPerformed(ActionEvent e){
		cbutton = (JButton)e.getSource();
		System.out.println("hi");
	}
	public void mouseClicked(MouseEvent e){
		int x= e.getX();
		int y=e.getY();
		JPanel canvas = (JPanel)e.getSource();
		if(cbutton.getText().equals("e")){
			canvas.getGraphics().drawOval(x-30,y-20,60,40);
			System.out.println("ellipse");
		}
		else if(cbutton.getText().equals("r"))
			canvas.getGraphics().drawRect(x-30,y-20,60,40);
		else
			canvas.getGraphics().drawRect(x-25,y-25,50,50);
	}
	public void mousePressed(MouseEvent e){}
	public void mouseReleased(MouseEvent e){}
	public void mouseEntered(MouseEvent e){}
	public void mouseExited(MouseEvent e){}
}

